package beans;

import java.util.List;

import interfaces.AlunoBeanRemote;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

import modelos.Aluno;

@Stateless
public class AlunoBean implements AlunoBeanRemote {

	@PersistenceContext(unitName="smae")
	public EntityManager em;
	
    public AlunoBean() {}
    
    public void persistirAluno(Aluno aluno){
    	em.persist(aluno);
    }
    
    public List<Aluno> listarAluno(){
    	Query query = em.createQuery("from Aluno");
    	@SuppressWarnings("unchecked")
		List<Aluno> alunos = query.getResultList();
    	return alunos;
    }

}
